home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / vernon.zip / SINX.PAS < prev    next >
Pascal/Delphi Source File  |  1989-02-17  |  862b  |  41 lines

  1. program SinofX;
  2.  
  3.    {  This program calculates sin(x) using the Taylor's series
  4.       expansion:
  5.                                i      (2i + 1)
  6.           sin(x)   =       (-1)     X
  7.                            ______________
  8.                              (2i + 1) !
  9.  
  10.       by continuing to calculate a new term until the value has
  11.       been calculated to within an accuracy of .0001              }
  12.  
  13.  
  14.    var   X : real;    I : integer;    Sum : real;
  15.  
  16. {$I Power.pas}
  17.  
  18. {I Neg1.pas}
  19.  
  20. {I Xval.pas}
  21.  
  22. {I Fact.pas}
  23.  
  24. {I Term.pas}
  25.  
  26.    begin
  27.       writeln('Enter a value for X to find the value sin(x):');
  28.       readln(x);
  29.  
  30.       sum := 0;
  31.       I := 0;
  32.  
  33.       while  { accurracy still less than .0001 }  do begin
  34.           Sum := Sum + Term(X,I);
  35.           I := I + 1
  36.           end;
  37.  
  38.       writeln(' sin(x) = ', Sum:12:4)
  39.    end.
  40.  
  41.